/*
Module : FTPTRANSFERDLG.H
Purpose: Defines the interface for an MFC dialog which performs FTP uploads 
         and downloads similiar to the Internet Explorer download dialog
Created: PJN / 3-01-2000

Copyright (c) 2000 - 2008 by PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)

All rights reserved.

Copyright / Usage Details:

You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. 

All rights reserved.

*/


/////////////////////////// Macros //////////////////////////////////

#pragma once

#ifndef __FTPTRANSFER_H__
#define __FTPTRANSFER_H__

#ifndef CFTPTRANSFERDLG_EXT_CLASS
#define CFTPTRANSFERDLG_EXT_CLASS
#endif


/////////////////////////// Includes ////////////////////////////////

#ifndef __FTPTRANSFERER_H__
#include "FTPTransferer.h"
#endif


/////////////////////////// Classes /////////////////////////////////

class CFTPTRANSFERDLG_EXT_CLASS CFTPTransferDlg : public CDialog,
                                                  public CFTPTransferer
{
public:
//Constructors / Destructors
	CFTPTransferDlg(CWnd* pParent = NULL);

protected:
	enum { IDD = IDD_FTPTRANSFER };
	CStatic	m_ctrlStatus;
	CStatic	m_ctrlTransferRate;
	CStatic	m_ctrlTimeLeft;
	CProgressCtrl	m_ctrlProgress;
	CStatic	m_ctrlFileStatus;
	CAnimateCtrl m_ctrlAnimate;

	virtual void DoDataExchange(CDataExchange* pDX);
	virtual BOOL OnInitDialog();
  virtual void TransferThread();
  virtual void SetPercentage(int nPercentage);
  virtual void SetTimeLeft(DWORD dwSecondsLeft, ULONGLONG nBytesRead, ULONGLONG nFileSize);
  virtual void SetStatus(LPCTSTR pszStatus);
  virtual void SetTransferRate(double KbPerSecond);
  virtual void OnProgress(ULONGLONG nBytesRead, BOOL bGotFileSize, ULONGLONG nTotalBytesToRead);
  virtual void HandleError(UINT nID, DWORD dwError);
  virtual void OnWininetStatusCallBack(HINTERNET hInternet, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
	
	afx_msg void OnDestroy();
	virtual void OnCancel();
	afx_msg void OnClose();
  afx_msg LRESULT OnThreadFinished(WPARAM wParam, LPARAM lParam);

	DECLARE_MESSAGE_MAP()
  DECLARE_DYNAMIC(CFTPTransferDlg);

  static UINT _TransferThread(LPVOID pParam);

//Member variables
  CString       m_sError;
  BOOL          m_bSafeToClose;
  ULONGLONG     m_nLastTotalBytes;
  DWORD         m_dwLastPercentage;
  DWORD         m_dwLastProgressTicks;
  DWORD         m_dwStartProgressTicks;
  CWinThread*   m_pThread;
};

#endif //__FTPTRANSFERDLG_H__
